using System;
namespace Microsoft.Phone.Controls.Maps.Core
{
	internal class TfeTileSource : TileSource
	{
		internal TfeCoverageMap TileCoverageMap
		{
			private get;
			set;
		}
		public bool CoverageMapLoaded
		{
			get
			{
				return this.TileCoverageMap != null && this.TileCoverageMap.Loaded;
			}
		}
		public int MinZoomLevel
		{
			get
			{
				if (this.TileCoverageMap != null)
				{
					return this.TileCoverageMap.MinZoomLevel;
				}
				return -1;
			}
		}
		public int MaxZoomLevel
		{
			get
			{
				if (this.TileCoverageMap != null)
				{
					return this.TileCoverageMap.MaxZoomLevel;
				}
				return -1;
			}
		}
		public TfeTileSource()
		{
		}
		public TfeTileSource(string uriFormat, Uri coverageMapUri) : base(uriFormat)
		{
			this.SetCoverageMapUri(coverageMapUri);
		}
		public void SetCoverageMapUri(Uri coverageMapUri)
		{
			if (coverageMapUri != null)
			{
				TfeCoverageMap.GetInstance(coverageMapUri, new TfeCoverageMapCallback(this.TfeCoverageMapLoaded));
				return;
			}
			this.TileCoverageMap = null;
		}
		public bool Covers(QuadKey quadKey)
		{
			return this.TileCoverageMap == null || this.TileCoverageMap.Covers(quadKey);
		}
		public int GetMaximumZoomLevel(QuadKey quadKey)
		{
			if (this.TileCoverageMap != null)
			{
				return this.TileCoverageMap.GetMaximumZoomLevel(quadKey);
			}
			return -1;
		}
		private void TfeCoverageMapLoaded(TfeCoverageMap coverageMap, object userState)
		{
			this.TileCoverageMap = coverageMap;
		}
	}
}
